<!DOCTYPE html>
<html lang="en">
<head>
    <title>退付书</title>
    <#include "../inc/header.ftl"/>
    <link rel="stylesheet" href="${prefix}/assets/custom/css/main.css?20240428"/>
</head>

<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">

    <div class="main-content">
        <div class="main-content-inner">

            <div class="page-content">
                <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" class="r_tablebr">
                    <tr>
                        <td class="r_nr">
                            <table width="99%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td class="r_title">河北省非税收入退付书</td>
                                </tr>
                            </table>
                            <form name="BackBillForm" id="BackBillForm" action="queryBackBillData" method="post">
                                <input name="filldate" type="hidden" id="filldate" value="${curDate?default("")}"/>
                                <table width="99%" border="0" cellpadding="0" cellspacing="0" class="r_zsdwbm">
                                    <tr>
                                        <td align="right">票据编号：
                                            <input name="backbillnum" type="text" id="backbillnum" value="" class="r_input2" style="width:100px;" />
                                        </td>
                                        <td>交易流水号：<input type="text" id="bankaffirm" name="bankaffirm" value="" class="r_input2" style="width:170px;"></td>
                                    </tr>
                                    <tr>
                                        <td align="center" class="r_zsdwbmwz">开票日期：<span id="filldateshow"></span></td>
                                    </tr>
                                </table>
                                <table width="99%" border="1" cellpadding="0" cellspacing="1" class="r_jcxx2">
                                    <tr>
                                        <td width="15%" align="right">付款人全称</td>
                                        <td width="35%"><input name="accountname" type="text" id="accountname" style="width:95%" readonly="readonly" value="" /></td>
                                        <td width="15%" align="right">收款人全称</td>
                                        <td width="35%"><input name="drawman" type="text" id="drawman" style="width:95%" readonly="readonly" value="" /></td>
                                    </tr>
                                    <tr>
                                        <td align="right">付款人账号</td>
                                        <td><input name="accountcode" type="text" id="accountcode" style="width:95%" readonly="readonly" value="" /></td>
                                        <td width="15%" align="right">收款人账号</td>
                                        <td><input name="drawaccount" type="text" id="drawaccount" style="width:95%" readonly="readonly" value="" /></td>
                                    </tr>
                                    <tr>
                                        <td align="right">付款人开户银行</td>
                                        <td><input name="bankname" type="text" id="bankname" style="width:95%" readonly="readonly" value="" /></td>
                                        <td width="15%" align="right">收款人开户银行</td>
                                        <td><input name="drawbank" type="text" id="drawbank" style="width:95%" readonly="readonly" value="" /></td>
                                    </tr>
                                    <tr>
                                        <td align="right">项目代码</td>
                                        <td><input name="itemcode" type="text" id="itemcode" style="width:95%" readonly="readonly" value="" /></td>
                                        <td align="right">项目名称</td>
                                        <td><input name="itemname" type="text" id="itemname" style="width:95%" readonly="readonly" value="" /></td>
                                    </tr>
                                </table>
                                <table width="99%" border="0" cellpadding="0" cellspacing="0" class="r_zsdwbm">
                                    <tr>
                                        <td align="right">金额（大写）：
                                            <input name="bigfund" type="text" id="bigfund" class="r_input"style="width:250px" readonly="readonly" value="" />
                                            （小写）：
                                            <input name="fund" type="text" id="fund" class="r_input" style="width:80px" readonly="readonly" value="" /></td>
                                    </tr>
                                </table>
                            </form>
                            <table width="99%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td height="40" align="right">
                                        <input type="button" name="button" id="button" class="r_button" onclick="queryBackBillData()" value="查询单据" />
                                        <input type="button" name="paybutton" id="paybutton"  class="r_button" onclick="pay()" value="付款" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>

            </div><!-- /.page-content -->

        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<!-- basic scripts -->
<#include "../inc/basicjs.ftl"/>
<script src="${prefix}/assets/custom/js/commonview.js"></script>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function(){
        var curr_time = new Date();
        var str = curr_time.getFullYear()+"-";
        str += curr_time.getMonth()+1+"-";
        str += curr_time.getDate()+"";
        $('#filldateshow').html(str);
    });
    //数据初始化
    function pay() {
        $('#BackBillForm').form({
            url: prefix + "/view/backpaybill/backbillpayview",
            onSubmit:function(){
                var isValid = $(this).form('validate');
                return isValid;
            },
            success:function(data) {
                var data = eval('(' + data + ')');
                if(data.success) {
                    location=prefix+'/view/backpaybill/backbillview';
                }
                alert(data.msg);
            }
        });
        $('#BackBillForm').submit();
    }
    function queryBackBillData() {
        var state = [{"key":"0","value":"查询错误"},{"key":"1","value":"正常"},{"key":"2","value":"账户类型不符"},{"key":"3","value":"已收款"},{"key":"4","value":"票据不可用"}];
        var backbillnum = $("#backbillnum").val();
        if(backbillnum=="") {
            $.messager.alert('提示','请输入退付书票据号!', 'info');
            $("#backbillnum").focus();
            return;
        }
        $.ajax({
            type: "POST",
            url: prefix+"/view/backpaybill/queryBackBillData",
            dataType: "json",
            data: { backbillnum: backbillnum},
            success: function (dataOne) {
                var data =new DOMParser().parseFromString(dataOne.data, "text/xml")

                $("#backbillnum").val($(data).find("backbillnum").text());
                $("#accountname").val($(data).find("accountname").text());
                $("#drawman").val($(data).find("drawman").text());
                $("#accountcode").val($(data).find("accountcode").text());
                $("#drawaccount").val($(data).find("drawaccount").text());
                $("#bankname").val($(data).find("bankname").text());
                $("#drawbank").val($(data).find("drawbank").text());
                $("#itemcode").val($(data).find("itemcode").text());
                $("#itemname").val($(data).find("itemname").text());
                $("#fund").val($(data).find("fund").text());
                $("#bigfund").val(upDigit($(data).find("fund").text()));
                var billstate = $(data).find("billstate").text();

                if(billstate!='1'){
                    $('#paybutton').attr('disabled',true);
                    for(var p in state) {
                        if(state[p].key==billstate) {
                            $.messager.alert('提示',state[p].value, 'info');
                        }
                    }
                }else{
                    $('#paybutton').attr('disabled',false);
                }
            }
        })
    }
</script>
</body>
</html>
